// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from '@/router/router.js'
import ElementUi from 'element-ui'
import axios from 'axios'
import ElTreeGrid from 'element-tree-grid'
import VueQuillEditor from 'vue-quill-editor' // 富文本编辑器
// import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/common.css'
// require styles
// import 'quill/dist/quill.core.css'
// import 'quill/dist/quill.snow.css'
// import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor /* { default global options } */)
// 使用element-tree-grid插件
Vue.component(ElTreeGrid.name, ElTreeGrid)
// 设置axios的默认基路径
axios.defaults.baseURL = 'http://localhost:8888/api/private/v1/'
// 在Vue原型上添加$axios方法
Vue.prototype.$axios = axios
// 每次发送请求前都在请求头中携带token指令
axios.interceptors.request.use(
  config => {
    config.headers.Authorization = localStorage.getItem('token')
    return config
  },
  error => {
    // Promise内部执行错误时会调用这个回调函数, Promise.reject直接返回一个失败的Promise对象
    return Promise.reject(error)
  }
)
Vue.use(ElementUi)
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  components: {
    App
  },
  template: '<App/>',
  router
})
